<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>${sys.sortName!''}</title>

<link rel="stylesheet" type="text/css" href="${basePath}/res/js/jquery-easyui/themes/gray/easyui.css">
<script type="text/javascript" src="${basePath}/res/js/jquery-easyui/jquery.min.js"></script>
<script type="text/javascript" src="${basePath}/res/js/jquery-easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${basePath}/res/js/common.js"></script>

<link rel="stylesheet" type="text/css" href="${basePath}/login/${sys.loginCode!''}/css/login.css">

<script type="text/javascript">
	if (self != top) {  //主页不允许在iframe中
		top.window.location.reload();
	}
</script>

</head>
<body style="visibility: hidden;">

<div class="crm-register-bg">
  <div class="crm-register-form">
    <header class="crm-login1-header">
      <h1>欢迎登录</h1>
    </header>
    <form id="ff" class="easyui-form" method="post" action="" data-options="novalidate:true">
    <div class="crm-register-body crm-login1-body">
        <div class="crm-register-input-warpper">
          <input type="text" class="crm-register-input easyui-validatebox" data-options="required:true,validType:'length[2,20]'" value="" name="user_name" id="user_name" placeholder="用户名" tabindex="1">
        </div>
        <div class="crm-register-input-warpper">
          <input type="password" class="crm-register-input easyui-validatebox" data-options="required:true" class="crm-register-input easyui-validatebox" value="" name="password" id="password" placeholder="密码" tabindex="1" onfocus="">
        </div>
    </div>
    <div class="crm-register-footer">
      <a href="javascript:login();" class="pg-btn-submit dinline-block " tabindex="3" act="login_btn">登     录</a>
    </div>
    </form>
    <p class="crm-loginfooter-info" style="">
      <a href="javascript: $('#user_name').val('readonly');" class="register_link" tabindex="6" act="reg_link"></a>
   
    </p>
  </div>
</div>

<script type="text/javascript">
$(function() {
	//获取焦点样式
	$("#ff :input").focus(function() {
		$(this).parent().addClass("actived");
	}).blur(function() {
		$(this).parent().removeClass("actived");
	});
	
	//设置默认焦点,并将光标移到最后
	{
		var theValue =$("#user_name").val(); 
		$("#user_name").val("").focus().val(theValue); //其原理就是获得焦点后重新把自己复制粘帖一下 
	}
	
	//处理回车事件
	$(window).keydown(function(event){//按键事件
		if(event.keyCode==13) //回车 或 tab键
		{
			var theId = $(':focus').attr("id");
			if(theId == "user_name")
			{//如果焦点是用户名，则将焦点称到密码
				var theValue =$("#password").val(); 
				$("#password").val("").focus().val(theValue); 
			}
			else if(theId == "password")
			{//如果焦点是密码，则直接登录
				login();
			}
		}
	});
	
	
});

function login() {
	if($("#ff").form('enableValidation').form('validate')) {
		var param = {"user_name":$(":input[name='user_name']").val(), 
					"password":$(":input[name='password']").val(), 
					"sysCode":"${sys.code!''}"};
		$.post("${basePath}/login", param, function(data) {
			if(data.code == "01") {
				location.href = "${basePath}/base/main/index?sysmd=${sysmd!''}";
			}else {
				showWarnMsg(data.msg);
			}
		});
	}
}
</script>

</body>
</html>